﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Collections;
using System.Drawing;
using System.Xml.Serialization;

namespace QbiconEditor
{
  [TypeConverter(typeof(ExpandableObjectConverter))]
  public class TextureInfo
  {
    private QRectangle destinationRect = new QRectangle();
    private QRectangle sourceRect = new QRectangle();

    public string KeyName
    {
      get;
      set;
    }

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public QRectangle DestinationRect
    {
      get
      {
       return this.destinationRect;
      }
      set
      {
        this.destinationRect = value; 
      }
    }

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public QRectangle SourceRect
    {
      get
      {
        return this.sourceRect;
      }
      set
      {
        this.sourceRect = value;
      }
    }

    public System.Drawing.Drawing2D.WrapMode WrapMode
    {
      get;
      set;
    }
  }

  [TypeConverter(typeof(ExpandableObjectConverter))]
    public class QPoint
    {
      public float X
      {
        get;
        set;
      }
      public float Y
      {
        get;
        set;
      }
    }

  public class CustomProperty
  {
    public string Name 
    {
      get;
      set;
    }

    public string Value
    {
      get;
      set;
    }
  }
    

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class QRectangleF
    {
        public float Top
        {
            get;
            set;
        }

        public float Left
        {
            get;
            set;
        }

        public float Width
        {
            get;
            set;
        }

        public float Height
        {
            get;
            set;
        }
    }
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class QRectangle
    {
      public int Top
      {
        get;
        set;
      }

      public int Left
      {
        get;
        set;
      }

      public int Width
      {
        get;
        set;
      }

      public int Height
      {
        get;
        set;
      }
    }

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class QPolygone
    {
      private List<QPoint> points = new List<QPoint>();

      public List<QPoint> Points
      {
        get
        {
          return this.points;  
        }

        set
        {
          this.points = value;
        }
      }
    }

    [__DynamicallyInvokable]
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class QObject
    {
        private List<CustomProperty> customProperties = new List<CustomProperty>();

        public string Name
        {
            get;
            set;
        }

        public TextureInfo Texture
        {
            get;
            set;
        }

        public string Type
        {
          get;
          set;
        }

        [XmlIgnore()]
        public Color Color
        {
            get;
            set;
        }

        [Browsable(false)]
        public int ColorARGB
        {
            get
            {
                return Color.ToArgb();
            }
            set
            {
                this.Color = Color.FromArgb(value);
            }
        }

        [TypeConverter(typeof(ExpandableObjectConverter))]
        public QPolygone Poly
        {
          get;
          set;
        }

        public bool Visible
        {
            get;
            set;
        }

        [TypeConverter(typeof(ExpandableObjectConverter))]
        public List<CustomProperty> CustomProperties
        {
          get
          {
           return this.customProperties; 
          }
          set
          {
            this.customProperties = value;
          }
        }
    }


    public class QMapLayer
    {
      private List<CustomProperty> customProperties = new List<CustomProperty>();
      private List<QObject> objects = new List<QObject>();
     
      [TypeConverter(typeof(ExpandableObjectConverter))]
      public List<QObject> Objects
      {
        get
        {
          return this.objects;
        }
        set
        {
          this.objects = value;
        }
      }

      public bool Visible
      {
        get;
        set;
      }
      public string Name
      {
        get;
        set;
      }
      public string Type
      {
        get;
        set;
      }

      [TypeConverter(typeof(ExpandableObjectConverter))]
      public List<CustomProperty> CustomProperties
      {
        get
        {
          return this.customProperties;
        }
        set
        {
          this.customProperties = value;
        }
      }
    }

    public class QMap
    {
        private List<CustomProperty> customProperties = new List<CustomProperty>();
        private List<QMapLayer> layers = new List<QMapLayer>();

        private Color backgroundColor = Color.White;
        [Browsable(false)]
        public int BackgroundColorARGB
        {
            get
            {
                return this.BackgroundColor.ToArgb();
            }
            set
            {
                this.BackgroundColor = Color.FromArgb(value);
            }
        }

        [XmlIgnore()]
        public Color BackgroundColor
        {
            get
            {
                return backgroundColor;   
            }
            set
            {
                this.backgroundColor = value;
            }
        }

        [TypeConverter(typeof(ExpandableObjectConverter))]
        public List<QMapLayer> Layers
        {
          get
          {
            return this.layers;
          }
          set
          {
            this.layers = value;
          }
        }

        public string Name
        {
            get;
            set;
        }

        [TypeConverter(typeof(ExpandableObjectConverter))]
        public List<CustomProperty> CustomProperties
        {
          get
          {
            return this.customProperties;
          }
          set
          {
            this.customProperties = value;
          }
        }

        public string Type
        {
          get;
          set;
        }
    }
}
